<?php
namespace app\admin\model;

use think\Db;
use think\facade\Config;
use think\Model;

class TestOrderPhone extends Model
{
    protected $table = 'bus_test_order_phone';

    public static function getTestPhone($request)
    {
        $where[] = ['test_order_table_id', '=', $request['order_id']];

        if($request['phone'] != ''){
            $where[] = ['phone', '=', $request['phone']];
        }
        return self::where($where)
                ->paginate($request['limit'], false, $request)
                ->each(function($item, $key){
                    switch ($item->order_phone_code) {
                        case '0':
                            $item->order_phone_code = '未处理';
                            break;
                        case '1':
                            $item->order_phone_code = '已处理';
                            break;
                        case '5':
                            $item->order_phone_code = '成功';
                            break;
                        case '6':
                            $item->order_phone_code = '失败';
                            break;

                        default:
                            $item->order_phone_code = '未知';
                            break;
                    }
                    switch ($item->isp_host) {
                        case '10086':
                            $item->isp_host = '移动';
                            break;
                        case '10000':
                            $item->isp_host = '电信';
                            break;
                        case '10010':
                            $item->isp_host = '联通';
                            break;
                        default:
                            $item->isp_host = '未知';
                            break;
                    }
                })
                ->toArray();
    }

}
